﻿@{
    ViewBag.Title = "DTcms后台登录";
}
@section HeaderContent{
    <link href="../login.css" rel="stylesheet" />
    <script type="text/javascript">
        if (window != top) {
            top.location.replace(location.href);
        }
    </script>
}
<div class="login-wrapper">
    <div class="login-header">
        <img src="/images/logo.png">
    </div>
    <div class="login-body">
        <div class="layui-card">
            <div class="layui-card-header">
                <i class="layui-icon layui-icon-engine"></i>&nbsp;&nbsp;用户登录
            </div>
            <form class="layui-card-body layui-form layui-form-pane">
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
                    <div class="layui-input-block">
                        <input name="username" type="text" placeholder="账号" class="layui-input" lay-verType="tips" lay-verify="required" required />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
                    <div class="layui-input-block">
                        <input name="password" type="password" placeholder="密码" class="layui-input" lay-verType="tips" lay-verify="required" required />
                    </div>
                </div>
                <div class="layui-form-item hide">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-vercode"></i></label>
                    <div class="layui-input-block">
                        <div class="layui-row inline-block">
                            <div class="layui-col-xs7">
                                <input name="code" value="1234" type="text" placeholder="验证码" class="layui-input" autocomplete="off" lay-verType="tips" lay-verify="required" required />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <a href="javascript:;" class="layui-link">帐号注册</a>
                    <a href="javascript:;" class="layui-link pull-right">忘记密码？</a>
                </div>
                <div class="layui-form-item">
                    <button lay-filter="login-submit" class="layui-btn layui-btn-fluid" id="btnSubmit" lay-submit>登 录</button>
                </div>
                <div class="layui-form-item login-other">
                    <label>第三方登录</label>
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-qq"></i></a>
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat"></i></a>
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo"></i></a>
                </div>
            </form>
        </div>
    </div>
</div>
@section Scripts{
    <script type="text/javascript">
        layui.use(['layer', 'form', 'notice'], function () {
            var $ = layui.jquery, layer = layui.layer, form = layui.form, notice = layui.notice;

            // 表单提交
            form.on('submit(login-submit)', function (obj) {
                notice.msg('正在验证...', { icon: 4, close: true });
                $.ajax({
                    type: "POST",
                    url: "/WebApi/LoginJson",
                    dataType: "json",
                    data: obj.field,
                    timeout: 20000,
                    beforeSend: function (XMLHttpRequest) {
                        $("#btnSubmit").attr("disabled", true);
                    },
                    success: function (data, textStatus) {
                        notice.destroy();
                        if (data.status == 1) {
                            notice.msg('跳转中...', { icon: 1 });
                            location.href = "index";
                        } else {
                            layer.msg(data.msg, { icon: 2 });
                            $("#btnSubmit").attr("disabled", false);
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        notice.destroy();
                        $("#btnSubmit").attr("disabled", false);
                    }
                });
                return false;
            });

            // 图形验证码
            $('.login-captcha').click(function () {
                this.src = this.src + '?t=' + (new Date).getTime();
            });
        });
    </script>
}